package com.qboot.quartz.listener;

import com.qboot.quartz.service.QuartzService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.ContextRefreshedEvent;

/**
 * spring 容器加载完毕后事件，启动任务调用
 *
 * @author Tellsea
 * @date 2023/2/14
 */
@Configuration
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class ApplicationQuartzListener implements ApplicationListener<ContextRefreshedEvent> {

    private final QuartzService quartzService;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        quartzService.startScheduler();
    }
}
